<%@ page language="java" import="java.util.*,com.hs.core.db.*,com.hs.auth.model.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
PageUtil pageUtil = (PageUtil)request.getAttribute("dataList");
String loginId = (String)request.getAttribute("loginId");
String userName = (String)request.getAttribute("userName");

List dataList = null;
String pageStr = "";
int perpageCount = 0;
int currentPage = 0;
if(pageUtil != null){
	   dataList = pageUtil.getPageList();
	   pageStr = pageUtil.getPageStr();
	   perpageCount = pageUtil.getNumberPerPage();
	   currentPage = pageUtil.getCurrentPage();
}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<%@ include file="../include.jsp"%>   
  
<style>.tac{text-align:center}</style>
<script>
function searchData(){

searchform.submit();
}

function modifyData(accid){
	
     window.parent.oper.frameElement.src = "<%=basePath%>auth/userInfo.do?uid="+accid; 
 
}
 function deleteUser(id){
 	if(confirm("确定要删除该帐号吗?")){
 		authdwr.deleteUser(id,callback4delete);
 	}
 }
 function callback4delete(){
    alert("成功删除帐号!");
    searchform.submit();
    window.parent.oper.frameElement.src = "<%=basePath%>auth/userInfo.do";
    //window.parent.list.frameElement.src = "<%=basePath%>auth/listUser.do"; 
    
 }
 function addUser(){
 	     window.parent.oper.frameElement.src = "<%=basePath%>auth/userInfo.do"; 
 	
 
 }
</script>
</head>
<body>
  <div class="cont"> 
    <form name="searchform" action="<%=basePath %>auth/listUser.do" method="post">
 
        <table border="0" cellpadding="0" cellspacing="0" class="tableForm">
			        <tr>
			          <th width="10%">姓名：</th>
			          <td width="34%"><input name="userName" type="text"   value="<%=userName==null?"":userName %>"  />
					</td> 
			          <th width="10%">帐号</th>
			          <td width="34%"><input name="loginId" type="text" value="<%=loginId==null?"":loginId %>"  /> 
					</td>
			        <td width="6%">
			              <input onclick="searchData();" type="button" value="查询" class="btn btn-primary"/> </td>
	                     <td width="6%"><input onclick="addUser();" type="button" value="新增人员" class="btn btn-primary"/> </td>
	                      
			        </tr>
		  </table> 
        </form>
         <div class="listWrap">
        <table border="0" cellpadding="0" cellspacing="0" align=center class="tableList">
          <tr> 
            <th width="5%">序号</th>
            <th width="15%">帐号</th>
            <th width="20%">姓名</th>  
            <th width="35%">账户权限</th>   
            <th width="10%">修改</th> 
            <th width="10%">删除</th> 
          </tr>
          <%if(dataList != null && dataList.size()>0){ 
                DBMgr dbo = DBMgr.getDbUtilInst(request.getSession().getServletContext());
			    for(int i =0;i<dataList.size();i++){
			       HsAccount obj = (HsAccount)dataList.get(i); 
			       HsUserinfo userinfo = obj.getUserinfo();
			       String rolename = "";
			       List roleList = dbo.queryList("select (select rolename from HS_ROLE where id =roleid) as rolename from HS_ACCROLE where accid=?",new Object[]{obj.getId()});
			       if(roleList.size()>0){
			       	  	Map role = (Map)roleList.get(0);
			       	  	rolename = (String)role.get("ROLENAME");
			       }
			       
			%>
			<tr> 
			<td align=center><%=perpageCount*(currentPage-1)+i+1 %></td>
			<td align=center><%=obj.getLoginid()==null?"":obj.getLoginid() %></td>
			<td align=center><%=userinfo.getUsername() %></td> 
			<td>
			<%=rolename %>
			</td> 
   			<td align="center"><input onclick="modifyData('<%=obj.getId() %>');" type="button" value="修改"  class="btn btn-primary"/></td>
 			<td align="center"><%if(!"system".equals(obj.getLoginid())){ %><input onclick="deleteUser('<%=obj.getId() %>');" type="button" value="删除" class="btn btn-primary"/><%} %> </td>  
			</tr> 
			
			<%}}else{ %>
			<tr>
            <td colspan=6 align="center"><font color=red><strong>当前没有人员信息！</strong></font></td>
          </tr>
          <%} %>
           
        </table> 
  
  <div class="pageWrap">
        <div class="result"></div>
        <div class="page">
              <%=pageStr %>
        </div>
    </div>
    </div>
</div>
</body>
</html>
